package com.bosssoft.ct.springcloud.pojo.dto;

import com.bosssoft.ct.springcloud.pojo.entity.User;
import lombok.*;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author ChenTong
 * @version 1.0
 * @description user
 * @date 2020/6/21 17:25
 * @modified
 **/
public class UserDTO extends BaseDTO implements Serializable {
    private String username;
    private String password;
    private String email;
    private Boolean state;
    private String mobile;

    public User dtoToEntity(){
        User user = new User();
        BeanUtils.copyProperties(this,user);
        return user;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Boolean getState() {
        return state;
    }

    public void setState(Boolean state) {
        this.state = state;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserDTO userDTO = (UserDTO) o;
        return Objects.equals(username, userDTO.username) &&
                Objects.equals(password, userDTO.password) &&
                Objects.equals(email, userDTO.email) &&
                Objects.equals(state, userDTO.state) &&
                Objects.equals(mobile, userDTO.mobile);
    }

    @Override
    public int hashCode() {
        return Objects.hash(username, password, email, state, mobile);
    }
}
